<template>
	<view>

		<view class="bg-white">
			<list1 :list="shop_list" :islog="islog" :log="log" :tabindex="tabindex"> </list1>
		</view>


	</view>
</template>

<script>
	import list1 from "./list1.vue";


	export default {
		components: {
			list1
		},
		data() {
			return {
				set: {},
				NavList: [],
				statistics: {},
				shop_list: [],
				tabindex: 0,
				islog: true,
				log: '加载中',
				url: '',
				search_key: ''

			}
		},
		onLoad(on) {
			this.tag_name = on.name;
			var pages = getCurrentPages()
			let currentRoute = pages[pages.length - 1].route;
			this.api_path = currentRoute.match(/pages\/(\S*)\//)[1];
			this.page = 1;
			this.shop_init();
		},
		methods: {
			on_search() {
				uni.navigateTo({
					url: '/pages/' + this.api_path + '/shop_search?search_key=' + this.search_key
				})
			},
			on_index(id) {
				uni.navigateTo({
					url: '/pages/' + this.api_path + '/nav_list?id=' + id
				})
			},
			on_tab(index) {
				this.shop_list = [];
				this.islog = true;
				this.page = 1;
				this.log = '加载中';
				this.tabindex = index;
				this.shop_init(this.tabindex);
			},
			shop_init() {
				uni.setNavigationBarTitle({
					title: this.tag_name
				})
				var that = this;
				let requestParams = {
					page: this.page, 
					tag_name: this.tag_name,
				};
				this.Http.post('/plugin.php/banmichaoqiangbizhi/api/index/shop_list', requestParams).then(ret => {
					this.url = ret.img_url
					if (ret.status == 200) {
						if (that.page == 1) {
							this.shop_list = ret.data.shop_list.data;
						} else {
							if (ret.data.shop_list.data.length > 0) {
								for (var i = 0; i < ret.data.shop_list.data.length; i++) {
									that.shop_list.push(ret.data.shop_list.data[i]);
								}
							}
							if (ret.data.shop_list.data < 10) {
								this.log = "没有数据了"
							}
						}
						setTimeout(() => {
							that.isinit = false;
							that.islog = false;
						}, 100)


					}
				})
			},
		},
		onReachBottom() {
			this.jiazai = "加载中...";
			this.page = this.page += 1;
			this.shop_init();
		},
	}
</script>

<style>
	.tab_list {
		font-weight: 800;
		border-bottom: solid 5rpx #0071FE;
		padding-bottom: 10rpx;
		color: #0071FE;
	}

	.tab_list_w {
		border-bottom: solid 5rpx #fff;
		padding-bottom: 10rpx;
		color: #7B7B7B;
	}

	.yuanzi {
		background-color: #F6F7FB;
		margin: 2px;
		padding-right: 5px;
		padding-left: 5px;
		padding-top: 2px;
		padding-bottom: 2px;
		font-size: 10px;
		color: #707072;
		border-radius: 12px;
	}

	.shop_index_bj {
		height: 450rpx;
		width: 100%;
		background-repeat: no-repeat;
		background-size: 100% 100%;
	}
</style>